#!/bin/bash
trap 'echo Abort ; exit 1' ERR

if [ $1 -a $1 == clean ] ; then 
	echo Clean U-Boot.
	rm u-boot-2008.10 -rf
	exit 0
fi

echo Build U-Boot.
if [ ! -d u-boot-2008.10 ] ; then
	tar jxf u-boot-2008.10.tar.bz2
	( cd u-boot-2008.10 ; patch --silent -p1 < ../u-boot-2008.10.patch )
fi
cd u-boot-2008.10
make at91sam9263ek_config > /dev/null
make > /dev/null
cp u-boot.bin /opt/armgcc/deploy/
cp tools/mkimage /opt/armgcc/deploy/
